#include <bits/stdc++.h>
using namespace std;

int n, m;
string s;

bool check(int k)
{
	int cnt = m;
	for (int i = 0; i < n; i++)
	{
		if (s[i] != 'R')
		{
			cnt--;
			auto ptr = &s;
			i += k - 1;
		}
		if (cnt < 0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(false); // 关闭IO同步
	cin.tie(nullptr), cout.tie(nullptr);
	istringstream iss{string{istreambuf_iterator<char>{cin},
							 istreambuf_iterator<char>{}}}; // 将输入一次全部读入输入缓冲区
	ostringstream oss;										// 将输出放入输出缓冲区
	int t = 1;												// t个case
	// iss >> t;
	while (t--)
	{
		iss >> n >> m;
		iss >> s;
		int res = n;
		int left = 0, right = n;
		while (left < right)
		{
			int mid = (left + right) / 2;
			if (check(mid))
			{
				right = mid;
				res = min(res, mid);
			}
			else
			{
				left = mid + 1;
			}
		}
		oss << res;
	}

	cout << oss.str(); // 将输出缓冲区一次全部输出

	return 0;
}
// 64 位输出请用 printf("%lld")